<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
class Interviewer_model extends CI_Model{
    public function __construct() {
        parent::__construct();
        $this->load->database();
    }
    public function loadInterviewerPass($PositionInterview)
    {
        $sql="SELECT DISTINCT CV_ID FROM `Interview` WHERE Result='passed' and PositionInterview='$PositionInterview' GROUP BY CV_ID HAVING COUNT(CV_ID)>=1";
        $query=$this->db->query($sql);
        return $query;
    }
    public function loadInterviewerPassByCVID($CV_ID)
    {
        $this->db->where('CV_ID',$CV_ID);
        $query=$this->db->get('CV');
        return $query;
    }
    public function getInformationInterviewByID($CV_ID)
    {
        $this->db->where('CV_ID',$CV_ID);
        $query=$this->db->get('Interview');
        return $query;
    }
    public function getFullNameByCVID($CV_ID)
    {
        $sql="select * from CV where CV_ID=$CV_ID";
        $query=$this->db->query($sql);
        return $query;
    }
    public function insertInterview($TestDate,$Interviewer,$Hour,$CV_ID,$CV_UserName,$CV_Status,$Round,$PositionInterview)
    {
        $insert_interview=array('TestDate'=>$TestDate,
            'Interviewer'=>$Interviewer,
            'Hour'=>$Hour,
            'CV_ID'=>$CV_ID,
            'CV_UserName'=>$CV_UserName,
            'CV_Status'=>$CV_Status,
            'Round'=>$Round,
            'PositionInterview'=>$PositionInterview);
        $insertinterview=$this->db->insert('Interview',$insert_interview);
        return $insertinterview;
    }
    public function getInterviewByInterviewID($Interview_ID)
    {
        $this->db->where('Interview_ID',$Interview_ID);
        $query=$this->db->get('Interview');
        return $query;
    }
    public function editInterview($Interview_ID,$UpdateDate,$CV_UserName,$CV_Status,$Result,$PositionInterview)
    {
        $edit_interview=array(
            'UpdateDate'=>$UpdateDate,
            'CV_UserName'=>$CV_UserName,
            'CV_Status'=>$CV_Status,
            'Result'=>$Result,
            'PositionInterview'=>$PositionInterview
        );
        $editinterview=$this->db->update('Interview',$edit_interview,array('Interview_ID'=>$Interview_ID));
        return $editinterview;
    }
}
?>
